package org.checkboo.hopefullyengine.scenegraph;

import org.checkboo.math.Matrix44f;
import org.checkboo.math.Quaternion;
import org.checkboo.math.Vector3f;

public class Node {
	
	private String name;
	private Quaternion localRotation;
	private Vector3f localTranslation;
	private Vector3f localScale;
	private Matrix44f worldTransform;
	private Matrix44f transform;
	private boolean render;
	
	public Node(String name){
		this.name = name;
		this.localRotation = new Quaternion();
		this.localTranslation = new Vector3f();
		this.localScale = new Vector3f(1.0f, 1.0f, 1.0f);
		this.worldTransform = new Matrix44f();
		this.worldTransform.identity();
		this.render = true;
	}
	
	public Node(String name, Quaternion localRotation, Vector3f localTranslation, Vector3f localScale){
		this.name = name;
		this.localRotation = localRotation;
		this.localTranslation = localTranslation;
		this.localScale = localScale;
		this.worldTransform = new Matrix44f();
		this.worldTransform.identity();
		this.render = true;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Quaternion getLocalRotation() {
		return localRotation;
	}

	public void setLocalRotation(Quaternion localRotation) {
		this.localRotation = localRotation;
	}

	public Vector3f getLocalTranslation() {
		return localTranslation;
	}

	public void setLocalTranslation(Vector3f localTranslation) {
		this.localTranslation = localTranslation;
	}

	public Vector3f getLocalScale() {
		return localScale;
	}

	public void setLocalScale(Vector3f localScale) {
		this.localScale = localScale;
	}

	public Matrix44f getLocalTransform(){
		if(null == this.transform)
			this.transform = new Matrix44f();
		this.transform.identity();
		this.transform.rotate(this.localRotation.toRotationMatrix());
		this.transform.scale(this.localScale);
		this.transform.translate(this.localTranslation);
		return this.transform;
	}
	
	public Matrix44f getWorldTransform(){
		return this.worldTransform;
	}

	public boolean isRender() {
		return render;
	}

	public void setRender(boolean render) {
		this.render = render;
	}
}
